package com.example.forum.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.forum.MyQuery;
import com.example.forum.entity.TRegion;
import com.example.forum.service.ITRegionService;
import com.example.forum.vo.JsonResult;
import com.example.forum.vo.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author why
 * @since 2020-04-22
 */
@RestController
@RequestMapping("Region")
public class TRegionController {
    @Autowired
    ITRegionService regionService;

    /**
     * 区 查询
     * @param pageIndex
     * @param pageSize
     * @return
     */
    @GetMapping("GetRegionPaged")
    public JsonResult getRegionPaged(@RequestParam(defaultValue = "1") Integer pageIndex,
                                     @RequestParam(defaultValue = "10") Integer pageSize){
        IPage<TRegion> pageData = regionService.page(new Page<>(pageIndex, pageSize), new MyQuery<TRegion>());
        return new JsonResult(HttpStatus.OK,"成功",new PageDto(pageData.getTotal(),pageData.getRecords()));
    }
}
